#  二十层的网络 输入的深度和速度都在变化
import torch.nn as nn


class Conv1d(nn.Module):
    def __init__(self, in_seq_len=20, out_seq_len=184):
        super(Conv1d, self).__init__()
        self.in_seq_len = in_seq_len
        self.out_seq_len = out_seq_len

        self.conv1 = nn.Sequential(
            # (b,2,20) -> (b,16,18)
            nn.Conv1d(in_channels=2, out_channels=16, kernel_size=3),
            nn.ReLU(inplace=True),
            # (b,16,1,18) -> (b,16,1,9)
            # nn.AvgPool2d(1, 2)
        )

        self.conv2 = nn.Sequential(
            # (b,16,18) -> (b,32,16)
            nn.Conv1d(in_channels=16, out_channels=32, kernel_size=3),
            nn.ReLU(inplace=True),
            # (b,64,1,8) -> (b,64,1,4)
            # nn.AvgPool2d(1, 2)
        )
        self.conv3 = nn.Sequential(
            # (b,32,16) -> (b,64,14)
            nn.Conv1d(in_channels=32, out_channels=64, kernel_size=3),
            nn.ReLU(inplace=True),
            # (b,64,1,8) -> (b,64,1,4)
            # nn.AvgPool2d(1, 2)
        )

        self.fc = nn.Sequential(
            nn.Linear(64*14, 512),
            nn.ReLU(inplace=True),
            nn.Linear(512, 256),
            nn.ReLU(inplace=True),
            nn.Linear(256, self.out_seq_len)
        )

    def forward(self, x):

        x = self.conv1(x)
        x = self.conv2(x)
        x = self.conv3(x)
        x = x.view(x.shape[0], 1, -1)

        out = self.fc(x)
        return out

